home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Online / Qpopper / pop_log.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-16  |  1.7 KB  |  75 lines

  1. /*
  2.  * Copyright (c) 1989 Regents of the University of California.
  3.  * All rights reserved.  The Berkeley software License Agreement
  4.  * specifies the terms and conditions for redistribution.
  5.  */
  6.  
  7. #ifndef lint
  8. static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
  9. static char SccsId[] = "@(#)@(#)pop_log.c    2.1  2.1 3/18/91";
  10. #endif
  11.  
  12. #include <stdio.h>
  13. #include <sys/types.h>
  14. #include <varargs.h>
  15. #include "popper.h"
  16.  
  17. /* 
  18.  *  log:    Make a log entry
  19.  */
  20.  
  21. static char msgbuf[MAXLINELEN];
  22.  
  23. pop_log(va_alist)
  24. va_dcl
  25. {
  26.     va_list     ap;
  27.     POP     *   p;
  28.     int         stat;
  29.     char    *   format;
  30. #ifdef PYRAMID
  31.     char    *   arg1, *arg2, *arg3, *arg4, *arg5, *arg6;
  32. #endif
  33.     char    *   date_time;
  34.     time_t    clock;
  35.  
  36.     va_start(ap);
  37.     p = va_arg(ap,POP *);
  38.     stat = va_arg(ap,int);
  39.     format = va_arg(ap,char *);
  40. #ifdef PYRAMID
  41.     arg1 = va_arg(ap, char *);
  42.     arg2 = va_arg(ap, char *);
  43.     arg3 = va_arg(ap, char *);
  44.     arg4 = va_arg(ap, char *);
  45.     arg5 = va_arg(ap, char *);
  46.     arg6 = va_arg(ap, char *);
  47. #endif
  48.  
  49. #ifdef HAVE_VSPRINTF
  50.         vsprintf(msgbuf,format,ap);
  51. #else
  52. # ifdef PYRAMID
  53.         (void)sprintf(msgbuf,format, arg1, arg2, arg3, arg4, arg5, arg6);
  54. # else
  55.         (void)sprintf (msgbuf,format,((int *)ap)[0],((int *)ap)[1],((int *)ap)[2],
  56.                 ((int *)ap)[3],((int *)ap)[4],((int *)ap)[5]);
  57. # endif
  58.     va_end(ap);
  59. #endif
  60.  
  61.     if (p->debug && p->trace) {
  62.     clock = time(0);
  63.     date_time = (char *)ctime(&clock);
  64.     date_time[strlen(date_time) - 1] = '\0';
  65.     (void)fprintf(p->trace,"%s [%d] %s\n",date_time, getpid(), msgbuf);
  66.         (void)fprintf(p->trace,"%s \n", date_time);
  67.         (void)fflush(p->trace);
  68.     }
  69.     else {
  70.         syslog (stat,"%s",msgbuf);
  71.     }
  72.  
  73.     return(stat);
  74. }
  75.